package com.example.system.tools;

/**
 * @PackageName: com.qidi.platform.common.tools
 * @Description: 执行结果类型
 * @Create: 2019-10-28 16:12
 */
public enum ResultEnum {
    /**
     * 执行成功
     */
    SUCCESS("0", "执行成功！"),
    /**
     * 执行失败
     */
    FAIL("1", "执行失败！");

    /**
     * 编码
     */
    private final String code;
    /**
     * 描述
     */
    private final String msg;

    ResultEnum(String code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }
    /**
    * @Description: 根据code获取枚举
    * @CreateTime: 16:24
    * @Version: 1.0
     *
     * @param code
     * @return
     */
    public static ResultEnum getResultEnum(String code) {
        for (ResultEnum resultEnum : ResultEnum.values()) {
            if (resultEnum.getCode().equals(code)) {
                return resultEnum;
            }
        }
        return null;
    }
}
